import Mock from 'mockjs'

// 许可证申报
const List = []
const count = 100

for (let i = 0; i < count; i++) {
  List.push(Mock.mock({
    id: '@increment', // 企业id
    enterpriseName: '@first', // 企业名称
    reportingTime: +Mock.Random.date('T'), // 申报时间
    registrant: '@first', // 登记人
    leadingCadre: '@first', // 企业负责人
    'enterpriseType|1': [1,2], // 单位类型
    'enterpriseStatus|1': [1,2], // 单位状态
    dateOfIssue: +Mock.Random.date('T'), // 发证日期
    effectiveDate: +Mock.Random.date('T'), // 有效日期
    licenceImgUrls: [
      {name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'},
      {name: 'food2.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}
    ]
  }))
}

// 许可证申报统计
const List1 = []

for (let i = 0; i < count; i++) {
  List1.push(Mock.mock({
    id: '@increment', // 企业id
    enterpriseName: '@first', // 企业名称
    'resolution|1': ['未处理', '同意', '不同意'],
    licenceImgUrls: [
      {name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'},
      {name: 'food2.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}
    ] // 许可证图片
  }))
}

export default [
  // 许可证申报页面
  {
    url: '/DeclarePermitLst.asmx/getEnterpriseDeclarePermitLst',
    type: 'get',
    response: config => {
      const { page = 1, limit = 20, sort } = config.query

      const pageList = List.filter((item, index) => index < limit * page && index >= limit * (page - 1))

      return {
        code: 200,
        data: {
          total: List.length,
          licenceDelarationList: pageList
        }
      }
    }
  },
  {
    url: '/DeclarePermitLst.asmx/getLicenceBaseInfo',
    type: 'get',
    response: config => {
      const licenceBaseInfo = {
        enterpriseName: '企业',  // 企业名称
        registrant: '@first', // 登记人
        leadingCadre: '@first', // 企业负责人
      }
      return {
        code: 200,
        data: licenceBaseInfo
      }
    }
  },
  {
    url: '/DeclarePermitLst.asmx/getDeclarePermitInfo',
    type: 'get',
    response: config => {
      const { id } = config.query
      for (const licence of List) {
        if (licence.id === +id) {
          return {
            code: 200,
            data: licence
          }
        }
      }
    }
  },

  {
    url: '/DeclarePermitLst.asmx/InsertDeclarePermit',
    type: 'post',
    response: _ => {
      return {
        code: 200,
        data: 'success'
      }
    }
  },

  {
    url: '/getEnterpriseType',
    type: 'post',
    response: config => {
      const enterpriseTypeList = [
        {
          label: '企业类型1',
          value: 1
        },
        {
          label: '企业类型2',
          value: 2
        }
      ]
      return {
        code: 200,
        data: enterpriseTypeList
      }
    }
  },

  {
    url: '/getEnterpriseStatus',
    type: 'post',
    response: config => {
      const licenceBaseInfo = [
        {
          label: '单位状态1',
          value: 1
        },
        {
          label: '单位状态2',
          value: 2
        }
      ]
      return {
        code: 200,
        data: licenceBaseInfo
      }
    }
  },

  // 许可证申报列表页面
  {
    url: '/DeclarePermitLst.asmx/getRadPermitOverdue',
    type: 'get',
    response: config => {
      const { page = 1, limit = 20, sort } = config.query

      const pageList = List1.filter((item, index) => index < limit * page && index >= limit * (page - 1))

      return {
        code: 200,
        data: {
          total: List1.length,
          licenceStatisticsList: pageList
        }
      }
    }
  },
  {
    url: '/DeclarePermitLst.asmx/licenceStatisticsImgsList',
    type: 'get',
    response: config => {
      const { id } = config.query
      for (const licence of List1) {
        if (licence.id === +id) {
          return {
            code: 200,
            data: licence
          }
        }
      }
    }
  },
  {
    url: '/DeclarePermitLst.asmx/UpdateDeclarePermit',
    type: 'post',
    response: _ => {
      return {
        code: 200,
        data: 'success'
      }
    }
  }
]

